define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'sand_manager/sand/index' + location.search,
                    add_url: 'sand_manager/sand/add',
                    edit_url: 'sand_manager/sand/edit',
                    del_url: 'sand_manager/sand/del',
                    multi_url: 'sand_manager/sand/multi',
                    import_url: 'sand_manager/sand/import',
                    table: 'sand',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'store_no', title: __('Store_no'), operate: 'LIKE'},
                        {field: 'external_id', title: __('External_id'), operate: 'LIKE'},
                        {field: 'merchant_type', title: __('Merchant_type'), searchList: {"GENERAL_MERCHANT":__('General_merchant')}, formatter: Table.api.formatter.normal},
                        {field: 'merchant_short_name', title: __('Merchant_short_name'), operate: 'LIKE'},
                        {field: 'merchant_full_name', title: __('Merchant_full_name'), operate: 'LIKE'},
                        {field: 'liquidation_mode', title: __('Liquidation_mode'), searchList: {"T1":__('T1')}, formatter: Table.api.formatter.normal},
                        {field: 'province_code', title: __('Province_code'), operate: 'LIKE'},
                        {field: 'city_code', title: __('City_code'), operate: 'LIKE'},
                        {field: 'area_code', title: __('Area_code'), operate: 'LIKE'},
                        {field: 'address', title: __('Address'), operate: 'LIKE'},
                        {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
                        {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
                        {field: 'enterprise_nature', title: __('Enterprise_nature'), searchList: {"OTHER":__('Other'),"GOVERNMENT_INSTITUTION":__('Government_institution'),"INDIVIDUAL_BUSINESS":__('Individual_business'),"LIMITED_COMPANY":__('Limited_company'),"STOCK_COMPANY":__('Stock_company')}, formatter: Table.api.formatter.normal},
                        {field: 'business_license_type', title: __('Business_license_type'), searchList: {"NATIONAL_LEGAL_MERGE":__('National_legal_merge'),"NATIONAL_LEGAL":__('National_legal')}, formatter: Table.api.formatter.normal},
                        {field: 'social_credit_code', title: __('Social_credit_code'), operate: 'LIKE'},
                        {field: 'license_validity_type', title: __('License_validity_type'), searchList: {"CHOOSE_DATE":__('Choose_date'),"LONG_DATE":__('Long_date')}, formatter: Table.api.formatter.normal},
                        {field: 'license_start_date', title: __('License_start_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'license_end_date', title: __('License_end_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'register_address', title: __('Register_address'), operate: 'LIKE'},
                        {field: 'legal_person_name', title: __('Legal_person_name'), operate: 'LIKE'},
                        {field: 'legal_person_card_type', title: __('Legal_person_card_type'), searchList: {"5":__('Legal_person_card_type 5'),"4":__('Legal_person_card_type 4'),"3":__('Legal_person_card_type 3'),"2":__('Legal_person_card_type 2'),"1":__('Legal_person_card_type 1')}, formatter: Table.api.formatter.normal},
                        {field: 'legal_person_card_no', title: __('Legal_person_card_no'), operate: 'LIKE'},
                        {field: 'legal_person_card_address', title: __('Legal_person_card_address'), operate: 'LIKE'},
                        {field: 'legal_person_card_date_start', title: __('Legal_person_card_date_start'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'legal_person_card_date_end', title: __('Legal_person_card_date_end'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'contact_person_name', title: __('Contact_person_name'), operate: 'LIKE'},
                        {field: 'contact_person_type', title: __('Contact_person_type'), searchList: {"OTHER":__('Other'),"AGENT":__('Agent'),"CONTROLLER":__('Controller'),"LEGAL_PERSON":__('Legal_person')}, formatter: Table.api.formatter.normal},
                        {field: 'contact_person_phone', title: __('Contact_person_phone'), operate: 'LIKE'},
                        {field: 'contact_person_id_card_no', title: __('Contact_person_id_card_no'), operate: 'LIKE'},
                        {field: 'contact_person_card_date_start', title: __('Contact_person_card_date_start'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'contact_person_card_date_end', title: __('Contact_person_card_date_end'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'contact_person_card_address', title: __('Contact_person_card_address'), operate: 'LIKE'},
                        {field: 'email', title: __('Email'), operate: 'LIKE'},
                        {field: 'service_tel', title: __('Service_tel'), operate: 'LIKE'},
                        {field: 'merchant_category_code', title: __('Merchant_category_code'), operate: 'LIKE'},
                        {field: 'product_code', title: __('Product_code'), operate: 'LIKE'},
                        {field: 'pay_way', title: __('Pay_way'), searchList: {"SANDBAO":__('Sandbao'),"UNION_PAY":__('Union_pay'),"ALIPAY":__('Alipay'),"WEIXIN":__('Weixin')}, formatter: Table.api.formatter.normal},
                        {field: 'wechat_category_code', title: __('Wechat_category_code'), operate: 'LIKE'},
                        {field: 'mcc_category_code', title: __('Mcc_category_code'), operate: 'LIKE'},
                        {field: 'social_credit_code_img_url_image', title: __('Social_credit_code_img_url_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'id_card_front_img_url_image', title: __('Id_card_front_img_url_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'id_card_back_img_url_image', title: __('Id_card_back_img_url_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'ic_net_screen_shot_urll_image', title: __('Ic_net_screen_shot_urll_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'app_screenshot_img_url_image', title: __('App_screenshot_img_url_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'payments_img_url_image', title: __('Payments_img_url_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'other_supply_img_url_images', title: __('Other_supply_img_url_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        {field: 'notify_url', title: __('Notify_url'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        {field: 'sub_merchant_id', title: __('Sub_merchant_id'), operate: 'LIKE'},
                        {field: 'plat_public_key', title: __('Plat_public_key'), operate: 'LIKE'},
                        {field: 'status', title: __('Status'), searchList: {"RISK":__('Risk'),"UNAPPROVE":__('Unapprove'),"UNACTIVE":__('Unactive'),"ACTIVE":__('Active'),"FIRSTPASS":__('Firstpass'),"UNDERAPPROVAL":__('Underapproval'),"BUSIAPPROVAL":__('Busiapproval'),"CREATED":__('Created')}, formatter: Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [{
                        	
                        	name: 'detail',
                                text: __('Detail'),
                                icon: 'fa fa-list',
                                classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                                url: 'sand_manager/sand/submitdata'
                                
	


                            }], formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
